Replication materials
Dynamic attack and defense strength in international rugby union

This folder contains the data, Stan model files, and R scripts needed to reproduce the analyses, figures, and supplementary results reported in the paper and supplementary materials.

DATA

rugby_results_150326.csv
    Match-level dataset used throughout the analysis. Contains men's international rugby union results for 2020-2025, including home and away teams, scores, dates, neutral-venue indicators, and other match information used by the models and benchmark algorithms.

MAIN BAYESIAN MODELS

rugby_NB_model_RW.stan
    Weekly random-walk Bayesian paired-score model. Latent attack and defense strengths evolve on a regular weekly calendar grid.

rugby_NB_model_CTRW2.stan
    Continuous-time random-walk Bayesian paired-score model. Latent attack and defense innovation variance depends on the elapsed number of weeks between team appearances.

rugby_NB_model_TS.stan
    Two-speed event-gap Bayesian paired-score model. Extends the continuous-time random walk by combining elapsed-time diffusion with an additional active-appearance component.

rugby_NB_model_AR.stan
    Autoregressive AR(1) Bayesian paired-score model reported as a robustness check in the supplementary materials.

MAIN MODEL FITTING AND PLOTTING

rugby_fit_single_model.R
    Fits one selected Bayesian model to the full 2020-2025 sample, saves the fitted CmdStan object, parameter summaries, diagnostics, traceplot, posterior predictive results, and metadata used by subsequent plotting code. The model to be fitted is selected with the active_model setting.

rugby_plot_single_model.R
    Reads a saved full-sample Bayesian fit and produces the latent attack and defense strength summaries and figures used in the paper and supplementary materials, together with posterior predictive plots and the table of team match counts.

OUT-OF-SAMPLE BAYESIAN EVALUATION

rugby_oos_test_fit.R
    Runs the rolling event-week out-of-sample evaluation for the three main Bayesian models (RW, CTRW2, and TS) over the 2025 test period. Produces week-level performance results, aggregate performance statistics, diagnostics, and match-level predictions. Takes several hours to run.

rugby_oos_predict_plot.R
    Uses the match-level predictions from the Bayesian OOS evaluation together with the benchmark prediction files to create observed-versus-predicted figures and margin-error summaries.

BENCHMARK MODELS

rugby_oos_expon_smooth.R
    Fits and evaluates the exponential error-correction smoother (ECES) benchmark. Tunes the smoothing and home-advantage parameters on 2024 results, evaluates the selected specification out of sample in 2025, saves match-level predictions, and produces full-sample team-strength estimates.

rugby_oos_wr_algorithm.R
    Implements the World Rugby rankings benchmark. Reconstructs World Rugby-style ratings from the January 2020 starting ratings, evaluates point-difference and home-win predictions by held-out event week in 2025, and saves match-level predictions and full-sample rating trajectories.

PRIOR-SENSITIVITY ANALYSIS

rugby_NB_model_TS_sens.stan
    Two-speed model used for the prior-sensitivity analysis. Uses the broader alternative prior specification reported in the supplementary materials.

rugby_NB_model_AR_sens.stan
    AR(1) model used for the prior-sensitivity analysis. Uses the broader alternative priors reported in the supplementary materials, including Beta(2,2) priors for the autoregressive coefficients.

rugby_fit_sens_analysis.R
    Fits the TS and AR sensitivity models, saves their parameter summaries, and produces the sensitivity-analysis traceplots reported in the supplementary materials.

SUGGESTED ORDER OF EXECUTION

1. Full-sample Bayesian models:
       Run rugby_fit_single_model.R separately for RW, CTRW2, TS, and AR as required.
       Then run rugby_plot_single_model.R for the corresponding saved fits.

2. Prior sensitivity:
       Run rugby_fit_sens_analysis.R.

3. Bayesian out-of-sample evaluation:
       Run rugby_oos_test_fit.R.

4. Benchmark evaluations:
       Run rugby_oos_expon_smooth.R.
       Run rugby_oos_wr_algorithm.R.

5. Out-of-sample figures:
       Run rugby_oos_predict_plot.R after the Bayesian and benchmark match-prediction CSV files have been created.

NOTES

- The accepted paper's main model comparison uses RW, CTRW2, and TS. The AR model is retained for supplementary robustness analysis.
- All scripts assume the files are in the same project directory and use the R package here for path handling.
- The Bayesian models are estimated with CmdStan through the cmdstanr package, so a working CmdStan installation is required.
- The rugby_oos_test_fit.R script takes several hours to run. 
- Output CSV, RDS, PNG, and CmdStan sampling files are generated by the scripts.

